package com.ksd.web.controller.networkBean;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class BatchCmdRequest {
    private String method;
    private List<BatchCmdParameters> parameters;

    public static BatchCmdRequest setCmdParameters( BatchCmdIp ip1,String gw) {
        BatchCmdRequest request = new BatchCmdRequest();

        BatchCmdParameters parameters1 = new BatchCmdParameters();
        BatchCmdParameters parameters2 = new BatchCmdParameters();
        request.setMethod("batchCmd");
        List<BatchCmdParameters> parametersList = new ArrayList<BatchCmdParameters>();
        parameters1.setUri("ip/eth0");
        BatchCmdContent batchCmdContent1 = new BatchCmdContent();
        batchCmdContent1.setMethod("setIpMode");
        BatchCmdContentParameters batchCmdContentParameters1 = new BatchCmdContentParameters();
        batchCmdContentParameters1.setType("eth");
        batchCmdContentParameters1.setMode(1);

        BatchCmdIp ip2 = new BatchCmdIp();
        ip2.setNetlen(24);
        ip2.setVer(4);
        ip2.setIpaddr("192.168.168.88");

        List<BatchCmdIp> ips = new ArrayList<>();
        ips.add(ip1);
        ips.add(ip2);
        batchCmdContentParameters1.setIp(ips);

        batchCmdContent1.setParameters(batchCmdContentParameters1);
        parameters1.setContent(batchCmdContent1);
        parametersList.add(parameters1);


        parameters2.setUri("route");
        BatchCmdContent content2 = new BatchCmdContent();
        content2.setMethod("addRoute");

        BatchCmdContentParameters contentparameters2 = new BatchCmdContentParameters();
        contentparameters2.setIface("eth0");
        contentparameters2.setDest("");
        contentparameters2.setGw(gw);




        content2.setParameters(contentparameters2);
        parameters2.setContent(content2);
        parametersList.add(parameters2);



        BatchCmdParameters parameters3 = new BatchCmdParameters();
        parameters3.setUri("sys");
        BatchCmdContent content3 = new BatchCmdContent();
        content3.setMethod("saveConfig");
        parameters3.setContent(content3);
        parametersList.add(parameters3);

        request.setParameters(parametersList);
        return request;
    }
}
